<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Input;

class QuestionRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {   
        $rules = [];
        $is_type = Input::only('is_type')['is_type'];

        // 判断图片是否合格以及大小不能超过200*200
        if($is_type==3){
            $rules['answer.*'] = 'mimes:jpeg,gif,png|dimensions:max_width=300,max_height=300';//
        }

        return $rules;
    }


    public function messages(){
        return [
            'answer.*.mimes'=>'请不要上传非图片文件！',
            'answer.*.dimensions'=>'图片大小不能超过200*200！'
        ];
    }

}
